#include"ThreadPool.hpp"
#include"Task.hpp"
#include<cstdlib>


int main()
{
    srand((unsigned)time(nullptr));
    //std::unique_ptr<ThreadPool<func_t>> tp = std::make_unique<ThreadPool<func_t>>(5);
    ThreadPool<Task>* tp = new ThreadPool<Task>(9);
    
    tp->Init();//初始化线程池
    cout<<"Init Success"<<endl;
    tp->Start();//线程池开始运行
    cout<<"Start success"<<endl;

    int cnt = 8;
    while(cnt--)
    {
        cout<<"Start push Tasks"<<endl;
        int x = (rand()^getpid()) % 17;
        usleep(x*1000);
        int y = (rand()^getpid()) % 17;
        Task t(x,y);
        tp->PushTask(t);
        cout<<"cnt : "<<cnt<<endl;
        sleep(1);
    }

    tp->Stop();

    sleep(2);

    return 0;
}